﻿package mortal.game.scene3D.player.info
{
    import Message.Public.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.scene3D.layer3D.utils.*;
    import mortal.game.scene3D.player.entity.*;
    import mortal.game.view.chat.*;
    import mortal.mvc.core.*;

    public class SunbathSpeakUtil extends Object
    {
        public static var perform:int = 1;
        public static var dance:int = 2;
        public static var shoot:int = 3;
        public static var kiss:int = 4;
        private static var totalPro:int = 100;
        private static var typeObj:Object;

        public function SunbathSpeakUtil()
        {
            return;
        }// end function

        private static function initInfo() : void
        {
            var _loc_1:Array = null;
            var _loc_2:int = 0;
            var _loc_3:Object = null;
            var _loc_4:Array = null;
            if (typeObj == null)
            {
                _loc_1 = GameDefConfig.instance.xmlDic["SpeakOnTheBeach"].item;
                if (_loc_1)
                {
                    typeObj = {};
                    _loc_2 = 0;
                    while (_loc_2 < _loc_1.length)
                    {
                        
                        _loc_3 = _loc_1[_loc_2];
                        if (!typeObj[_loc_3.type + "-" + _loc_3.sex + "-" + _loc_3.vip])
                        {
                            typeObj[_loc_3.type + "-" + _loc_3.sex + "-" + _loc_3.vip] = [];
                        }
                        _loc_4 = typeObj[_loc_3.type + "-" + _loc_3.sex + "-" + _loc_3.vip];
                        _loc_4.push(_loc_3);
                        _loc_2++;
                    }
                }
            }
            return;
        }// end function

        public static function getSpeakStr(param1:int) : String
        {
            var _loc_7:Object = null;
            initInfo();
            if (typeObj == null)
            {
                return null;
            }
            var _loc_2:* = RolePlayer.instance.entityInfo.entityInfo.sex;
            var _loc_3:* = Cache.instance.vip.level == 0 ? (0) : (1);
            var _loc_4:* = typeObj[param1 + "-" + _loc_2 + "-" + _loc_3];
            if (_loc_4 == null)
            {
                return null;
            }
            var _loc_5:* = int(Math.random() * totalPro);
            var _loc_6:int = 0;
            while (_loc_6 < _loc_4.length)
            {
                
                _loc_7 = _loc_4[_loc_6];
                _loc_5 = _loc_5 - int(_loc_7.prob);
                if (_loc_5 < 0)
                {
                    return _loc_7.content;
                }
                _loc_6++;
            }
            return null;
        }// end function

        public static function speakByType(param1:int, param2:SEntityId = null) : void
        {
            if (param2)
            {
                if (EntityUtil.equal(RolePlayer.instance.entityInfo.entityInfo.entityId, param2) == false)
                {
                    return;
                }
            }
            var _loc_3:* = getSpeakStr(param1);
            if (_loc_3 == null)
            {
                return;
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.ChatSend, {content:_loc_3, area:ChatArea.Scene, isSystem:true}));
            return;
        }// end function

    }
}
